function validateForm()
{
  var fname=document.forms["myForm"]["fname"].value;
  if (fname == null || fname == "")
  {
    alert("First name must be filled out");
    return false;
  }


  var email =document.forms["myForm"]["email"].value;
  var atpos=email.indexOf("@");
  var dotpos=email.lastIndexOf(".");
  if (atpos<1 || dotpos<atpos+2 || dotpos+2>=email.length)
  {
    alert("Not a valid e-mail address");
    return false;
  }

  var pass = document.forms["myForm"]["password"].value;
  var regex = new RegExp("^[a-zA-Z0-9@_]*$");
  if(! regex.test(pass) || pass == null || pass == "")
  {
    alert("Invalid format of password.");
    return false;
  }

}

function validatesignin()
{
  var y =document.forms["myForm1"]["email"].value;
  var atpos=y.indexOf("@");
  var dotpos=y.lastIndexOf(".");
  if (atpos<1 || dotpos<atpos+2 || dotpos+2>=y.length)
  {
    alert("Not a valid e-mail address");
    return false;
  }

  var x=document.forms["myForm1"]["password"].value;
  if (x==null || x=="")
    {
    alert("Please fill your password");
    return false;
  }
}

function validateAppointment()
{
  var date = parseInt(document.forms["appointment"]["day"].value);
  var month = parseInt(document.forms["appointment"]["month"].value);
  var year = parseInt(document.forms["appointment"]["year"].value);
  var hour = parseInt(document.forms["appointment"]["hours"].value);
  var mins = parseInt(document.forms["appointment"]["minutes"].value);
  
  var d =  new Date(year,month-1,date,hour,mins,0,0);
  var today = new Date();
  if(today > d){
    alert("Appointment date and time should be in future.")
    return false;
  }

  var email =document.forms["appointment"]["to"].value;
  var atpos=email.indexOf("@");
  var dotpos=email.lastIndexOf(".");
  if (atpos<1 || dotpos<atpos+2 || dotpos+2>=email.length)
  {
    alert("Not a valid e-mail address");
    return false;
  }

  var msg = document.forms["appointment"]["comment"].value;
  if (msg == null || msg == "")
  {
    alert("Please enter message.");
    return false;
  }

}